namespace DataModels.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class AddStockFacilityRelationShip : DbMigration
    {
        public override void Up()
        {
            //DropPrimaryKey("dbo.StockStatus");
            AlterColumn("dbo.StockStatus", "FacCode", c => c.String(nullable: false, maxLength: 50, unicode: false));
            AlterColumn("dbo.StockStatus", "RequiredDetermine", c => c.Int(nullable: false));
            AlterColumn("dbo.StockStatus", "RequiredUnigold", c => c.Int(nullable: false));
            AlterColumn("dbo.StockStatus", "RequiredDBS", c => c.Int(nullable: false));
            AlterColumn("dbo.StockStatus", "ReportDate", c => c.DateTime(nullable: false));
            AlterColumn("dbo.StockStatus", "ReportYear", c => c.Int(nullable: false));
            AlterColumn("dbo.StockStatus", "ReportMonth", c => c.Int(nullable: false));
            AddPrimaryKey("dbo.StockStatus", new[] { "FacCode", "ReportDate" });
            CreateIndex("dbo.StockStatus", "FacCode");
            AddForeignKey("dbo.StockStatus", "FacCode", "dbo.Facilities", "FacCode", cascadeDelete: true);
        }
        
        public override void Down()
        {
            DropForeignKey("dbo.StockStatus", "FacCode", "dbo.Facilities");
            DropIndex("dbo.StockStatus", new[] { "FacCode" });
            DropPrimaryKey("dbo.StockStatus");
            AlterColumn("dbo.StockStatus", "ReportMonth", c => c.Int());
            AlterColumn("dbo.StockStatus", "ReportYear", c => c.Int());
            AlterColumn("dbo.StockStatus", "ReportDate", c => c.DateTime());
            AlterColumn("dbo.StockStatus", "RequiredDBS", c => c.Int());
            AlterColumn("dbo.StockStatus", "RequiredUnigold", c => c.Int());
            AlterColumn("dbo.StockStatus", "RequiredDetermine", c => c.Int());
            AlterColumn("dbo.StockStatus", "FacCode", c => c.String(nullable: false, maxLength: 50));
            //AddPrimaryKey("dbo.StockStatus", "FacCode");
        }
    }
}
